import java.util.Queue;

public class MyQueue {
    private int[] arr;
    private int front;
    private int rear;


    public MyQueue(int k) {
        arr = new int[k+1];
    }

    public boolean offer(int x) {
        if(isFully()) {
            return false;
        }
        arr[rear] = x;
        rear = (rear+1) % arr.length;
        return true;
    }

    public int poll() {
        if(isEmpty()) {
            return -1;
        }
        int ret = arr[front];
        front = (front+1) % arr.length;
        return ret;
    }

    public int peek() {
        if(!isEmpty()) {
            return -1;
        }
        return arr[front];
    }

    public boolean isFully() {
        if((rear+1) % arr.length == front) {
            return true;
        }
        return false;
    }

    public boolean isEmpty() {
        return  front == rear;
    }
}
